import java.util.Random;

public class  Role {
    private String name;
    private int blood;
    public Role(){}
    public Role(String name,int blood){
        this.name=name;
        this.blood=blood;
    }
    public void setName(String name)
    {
        this.name=name;
    }
    public String getName(){
    return this.name;
    }
    public void setBlood(int blood){
        this.blood=blood;
    }
    public int getBlood(){
        return this.blood;
    }
    public void attack(Role role)
    {
        Random index=new Random();
        int hurt=index.nextInt(20)+1;
        int remainblood=role.getBlood();
         remainblood=remainblood-hurt;
        remainblood=remainblood>0?remainblood:0;
        role.setBlood(remainblood);
        System.out.println(this.name+"举起拳头打了"+role.getName()+"一下"+","+"造成了"+hurt+"点伤害"+role.getName()+"还剩下"+
                role.getBlood()+"点血");

    }
}

